<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:include href="../admin.xsl" />
	<xsl:include href="../common/form.xsl" />
	<xsl:include href="../cp/path.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/admin/forms.css" type="text/css" media="all" />
		</head>
		<body>
			<xsl:call-template name="admin-header" />
			
			<div id="blocks">
				<div id="blocks_inner" />
			</div>
			
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;system;images_profiles')/data/response" mode="cp-path">
				<xsl:with-param name="activeLink">1</xsl:with-param>
			</xsl:apply-templates>
		</div>
		
		<h1>
			<xsl:if test="$method = 'add_images_profile'">
				<xsl:text>Новый профиль изображений</xsl:text>
			</xsl:if>
			<xsl:if test="$method = 'edit_images_profile'">
				<xsl:text>Редактирование профиля изображений</xsl:text>
			</xsl:if>
		</h1>
		
		<form action="{$baseURI}/admin/system/add_images_profile/save" method="post">
			<xsl:if test="$method = 'edit_images_profile'">
				<xsl:attribute name="action">
					<xsl:value-of select="concat($baseURI, '/admin/system/edit_images_profile/', $formPrefix, '/save')" />
				</xsl:attribute>
			</xsl:if>
			
			<xsl:apply-templates select="form/field[@name='title']" />
			<xsl:apply-templates select="form/field[@name='exit_type']" />
			<xsl:apply-templates select="form/field[@name='max_width']" />
			<xsl:apply-templates select="form/field[@name='max_height']" />
			<xsl:apply-templates select="form/field[@name='dir']" />
			
			<p>
				<input type="submit" value="Добавить профиль">
					<xsl:if test="$method = 'edit_image_profile'">
						<xsl:attribute name="value">
							<xsl:text>Сохранить</xsl:text>
						</xsl:attribute>
					</xsl:if>
				</input>
			</p>
		</form>
	</xsl:template>
	
	<xsl:template match="form/field[@name='exit_type']">
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{@id}">
					<xsl:value-of select="title" />
					<xsl:text>:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<select id="field_{@id}" class="form_input_select" type="text" name="data[{$formPrefix}][{@name}]">
					<option>
						<xsl:if test="value = 'jpg'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>jpg</xsl:text>
					</option>
					<option>
						<xsl:if test="value = 'gif'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>gif</xsl:text>
					</option>
					<option>
						<xsl:if test="value = 'png'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>png</xsl:text>
					</option>
				</select>
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
				<xsl:if test="help != ''">
					<br /><span class="form_field_help"><xsl:value-of select="help" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>